/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
SmPrintUIOptions::SmPrintUIOptions()
{
SmMathConfig* pConfig = SmModule::get()->GetConfig();
SAL_WARN_IF( !pConfig, "starmath", "SmConfig not found" ); if (!pConfig) return;
sal_Int32 nNumProps = 10, nIdx=0;
// create sequence of print UI options // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.)
m_aUIProperties.resize( nNumProps );
// load the math PrinterOptions into the custom tab
m_aUIProperties[nIdx].Name = "OptionsUIFile";
m_aUIProperties[nIdx++].Value <<= u"modules/smath/ui/printeroptions.ui"_ustr;
// create Section for formula (results in an extra tab page in dialog)
SvtModuleOptions aOpt;
OUString aAppGroupname(
SmResId( RID_PRINTUIOPT_PRODNAME ).
replaceFirst( "%s", aOpt.GetModuleName( SvtModuleOptions::EModule::MATH ) ) );
m_aUIProperties[nIdx++].Value = setGroupControlOpt(u"tabcontrol-page2"_ustr, aAppGroupname, u".HelpID:vcl:PrintDialog:TabPage:AppPage"_ustr);
// create a bool option for title row (matches to SID_PRINTTITLE)
m_aUIProperties[nIdx++].Value = setBoolControlOpt(u"title"_ustr, SmResId( RID_PRINTUIOPT_TITLE ),
u".HelpID:vcl:PrintDialog:TitleRow:CheckBox"_ustr,
PRTUIOPT_TITLE_ROW,
pConfig->IsPrintTitle()); // create a bool option for formula text (matches to SID_PRINTTEXT)
m_aUIProperties[nIdx++].Value = setBoolControlOpt(u"formulatext"_ustr, SmResId( RID_PRINTUIOPT_FRMLTXT ),
u".HelpID:vcl:PrintDialog:FormulaText:CheckBox"_ustr,
PRTUIOPT_FORMULA_TEXT,
pConfig->IsPrintFormulaText()); // create a bool option for border (matches to SID_PRINTFRAME)
m_aUIProperties[nIdx++].Value = setBoolControlOpt(u"borders"_ustr, SmResId( RID_PRINTUIOPT_BORDERS ),
u".HelpID:vcl:PrintDialog:Border:CheckBox"_ustr,
PRTUIOPT_BORDER,
pConfig->IsPrintFrame());
// create subgroup for print format
m_aUIProperties[nIdx++].Value = setSubgroupControlOpt(u"size"_ustr, SmResId( RID_PRINTUIOPT_SIZE ), OUString());
// create a radio button group for print format (matches to SID_PRINTSIZE)
Sequence< OUString > aChoices{
SmResId( RID_PRINTUIOPT_ORIGSIZE ),
SmResId( RID_PRINTUIOPT_FITTOPAGE ),
SmResId( RID_PRINTUIOPT_SCALING )
};
Sequence< OUString > aHelpIds{
u".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0"_ustr,
u".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1"_ustr,
u".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2"_ustr
};
Sequence< OUString > aWidgetIds{
u"originalsize"_ustr,
u"fittopage"_ustr,
u"scaling"_ustr
};
OUString aPrintFormatProp( PRTUIOPT_PRINT_FORMAT );
m_aUIProperties[nIdx++].Value = setChoiceRadiosControlOpt(aWidgetIds, OUString(),
aHelpIds,
aPrintFormatProp,
aChoices, static_cast< sal_Int32 >(pConfig->GetPrintSize())
);
// create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM)
vcl::PrinterOptionsHelper::UIControlOptions aRangeOpt( aPrintFormatProp, 2, true );
m_aUIProperties[nIdx++].Value = setRangeControlOpt(u"scalingspin"_ustr, OUString(),
u".HelpID:vcl:PrintDialog:PrintScale:NumericField"_ustr,
PRTUIOPT_PRINT_SCALE,
pConfig->GetPrintZoomFactor(), // initial value
10, // min value
1000, // max value
aRangeOpt);
case HANDLE_ALIGNMENT :
{ // SmHorAlign uses the same values as HorizontalAlignment
sal_Int16 nVal = 0;
*pValues >>= nVal; if(nVal < 0 || nVal > 2) throw IllegalArgumentException();
aFormat.SetHorAlign(static_cast<SmHorAlign>(nVal));
} break;
case HANDLE_RELATIVE_SPACING : case HANDLE_RELATIVE_LINE_SPACING : case HANDLE_RELATIVE_ROOT_SPACING : case HANDLE_RELATIVE_INDEX_SUPERSCRIPT : case HANDLE_RELATIVE_INDEX_SUBSCRIPT : case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT : case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH: case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH: case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT : case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE : case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE : case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE : case HANDLE_RELATIVE_BRACKET_DISTANCE : case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE : case HANDLE_RELATIVE_MATRIX_LINE_SPACING : case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING : case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT : case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT : case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE : case HANDLE_RELATIVE_OPERATOR_SPACING : case HANDLE_LEFT_MARGIN : case HANDLE_RIGHT_MARGIN : case HANDLE_TOP_MARGIN : case HANDLE_BOTTOM_MARGIN :
{
sal_Int16 nVal = 0;
*pValues >>= nVal; if(nVal < 0) throw IllegalArgumentException();
aFormat.SetDistance((*ppEntries)->mnMemberId, nVal);
} break; case HANDLE_IS_SCALE_ALL_BRACKETS :
aFormat.SetScaleNormalBrackets(*o3tl::doAccess<bool>(*pValues)); break; case HANDLE_PRINTER_NAME:
{ // embedded documents just ignore this property for now if ( pDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
{
SfxPrinter *pPrinter = pDocSh->GetPrinter ( ); if (pPrinter)
{
OUString sPrinterName; if ( !(*pValues >>= sPrinterName) ) throw IllegalArgumentException();
if ( !sPrinterName.isEmpty() )
{
VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName ); if (pNewPrinter->IsKnown())
pDocSh->SetPrinter ( pNewPrinter ); else
pNewPrinter.disposeAndClear();
}
}
}
} break; case HANDLE_PRINTER_SETUP:
{
Sequence < sal_Int8 > aSequence; if ( !(*pValues >>= aSequence) ) throw IllegalArgumentException();
pDocSh->SetPrinter( pPrinter );
} break; case HANDLE_SYMBOLS:
{ // this is set
Sequence < SymbolDescriptor > aSequence; if ( !(*pValues >>= aSequence) ) throw IllegalArgumentException();
// tdf#143213 // Collect all font settings and apply them at the end, since the font name change can be seen // after italic or bold settings and would then override them. for (sal_uInt16 nFontDesc = FNT_BEGIN; nFontDesc <= FNT_END; ++nFontDesc)
{ const SmFace& rFont = maFonts[nFontDesc]; if (rFont.GetFamilyName().isEmpty()) continue;
if (aFormat.GetFont(nFontDesc).GetFamilyName() != rFont.GetFamilyName())
{ const SmFace rOld = aFormat.GetFont(nFontDesc);
if (aFormat.GetFont(nFontDesc).GetFontSize() != rFont.GetFontSize())
{
aFormat.SetFontSize(nFontDesc, rFont.GetFontSize());
}
}
pDocSh->SetFormat( aFormat );
// #i67283# since about all of the above changes are likely to change // the formula size we have to recalculate the vis-area now
pDocSh->SetVisArea( tools::Rectangle( Point(0, 0), pDocSh->GetSize() ) );
}
if ( nullptr == pDocSh ) throw UnknownPropertyException();
const SmFormat & aFormat = pDocSh->GetFormat();
for (; *ppEntries; ppEntries++, pValue++ )
{ switch ( (*ppEntries)->mnHandle )
{ case HANDLE_FORMULA:
*pValue <<= pDocSh->GetText(); break; case HANDLE_FONT_NAME_MATH : case HANDLE_FONT_NAME_VARIABLES : case HANDLE_FONT_NAME_FUNCTIONS : case HANDLE_FONT_NAME_NUMBERS : case HANDLE_FONT_NAME_TEXT : case HANDLE_CUSTOM_FONT_NAME_SERIF : case HANDLE_CUSTOM_FONT_NAME_SANS : case HANDLE_CUSTOM_FONT_NAME_FIXED :
{ const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
*pValue <<= rFace.GetFamilyName();
} break; case HANDLE_CUSTOM_FONT_FIXED_POSTURE: case HANDLE_CUSTOM_FONT_SANS_POSTURE : case HANDLE_CUSTOM_FONT_SERIF_POSTURE: case HANDLE_FONT_MATH_POSTURE : case HANDLE_FONT_VARIABLES_POSTURE : case HANDLE_FONT_FUNCTIONS_POSTURE : case HANDLE_FONT_NUMBERS_POSTURE : case HANDLE_FONT_TEXT_POSTURE :
{ const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
*pValue <<= IsItalic( rFace );
} break; case HANDLE_CUSTOM_FONT_FIXED_WEIGHT : case HANDLE_CUSTOM_FONT_SANS_WEIGHT : case HANDLE_CUSTOM_FONT_SERIF_WEIGHT : case HANDLE_FONT_MATH_WEIGHT : case HANDLE_FONT_VARIABLES_WEIGHT : case HANDLE_FONT_FUNCTIONS_WEIGHT : case HANDLE_FONT_NUMBERS_WEIGHT : case HANDLE_FONT_TEXT_WEIGHT :
{ const SmFace & rFace = aFormat.GetFont((*ppEntries)->mnMemberId);
*pValue <<= IsBold( rFace );
} break; case HANDLE_BASE_FONT_HEIGHT :
{ // Point!
*pValue <<= sal_Int16(o3tl::convert(aFormat.GetBaseSize().Height(),
SmO3tlLengthUnit(), o3tl::Length::pt));
} break; case HANDLE_RELATIVE_FONT_HEIGHT_TEXT : case HANDLE_RELATIVE_FONT_HEIGHT_INDICES : case HANDLE_RELATIVE_FONT_HEIGHT_FUNCTIONS : case HANDLE_RELATIVE_FONT_HEIGHT_OPERATORS : case HANDLE_RELATIVE_FONT_HEIGHT_LIMITS :
*pValue <<= static_cast<sal_Int16>(aFormat.GetRelSize((*ppEntries)->mnMemberId)); break;
case HANDLE_IS_TEXT_MODE :
*pValue <<= aFormat.IsTextmode(); break;
case HANDLE_IS_RIGHT_TO_LEFT :
*pValue <<= aFormat.IsRightToLeft(); break;
case HANDLE_GREEK_CHAR_STYLE :
*pValue <<= aFormat.GetGreekCharStyle(); break;
case HANDLE_ALIGNMENT : // SmHorAlign uses the same values as HorizontalAlignment
*pValue <<= static_cast<sal_Int16>(aFormat.GetHorAlign()); break;
case HANDLE_RELATIVE_SPACING : case HANDLE_RELATIVE_LINE_SPACING : case HANDLE_RELATIVE_ROOT_SPACING : case HANDLE_RELATIVE_INDEX_SUPERSCRIPT : case HANDLE_RELATIVE_INDEX_SUBSCRIPT : case HANDLE_RELATIVE_FRACTION_NUMERATOR_HEIGHT : case HANDLE_RELATIVE_FRACTION_DENOMINATOR_DEPTH: case HANDLE_RELATIVE_FRACTION_BAR_EXCESS_LENGTH: case HANDLE_RELATIVE_FRACTION_BAR_LINE_WEIGHT : case HANDLE_RELATIVE_UPPER_LIMIT_DISTANCE : case HANDLE_RELATIVE_LOWER_LIMIT_DISTANCE : case HANDLE_RELATIVE_BRACKET_EXCESS_SIZE : case HANDLE_RELATIVE_BRACKET_DISTANCE : case HANDLE_RELATIVE_SCALE_BRACKET_EXCESS_SIZE : case HANDLE_RELATIVE_MATRIX_LINE_SPACING : case HANDLE_RELATIVE_MATRIX_COLUMN_SPACING : case HANDLE_RELATIVE_SYMBOL_PRIMARY_HEIGHT : case HANDLE_RELATIVE_SYMBOL_MINIMUM_HEIGHT : case HANDLE_RELATIVE_OPERATOR_EXCESS_SIZE : case HANDLE_RELATIVE_OPERATOR_SPACING : case HANDLE_LEFT_MARGIN : case HANDLE_RIGHT_MARGIN : case HANDLE_TOP_MARGIN : case HANDLE_BOTTOM_MARGIN :
*pValue <<= static_cast<sal_Int16>(aFormat.GetDistance((*ppEntries)->mnMemberId)); break; case HANDLE_IS_SCALE_ALL_BRACKETS :
*pValue <<= aFormat.IsScaleNormalBrackets(); break; case HANDLE_PRINTER_NAME:
{
SfxPrinter *pPrinter = pDocSh->GetPrinter ( );
*pValue <<= pPrinter ? pPrinter->GetName() : OUString();
} break; case HANDLE_PRINTER_SETUP:
{
SfxPrinter *pPrinter = pDocSh->GetPrinter (); if (pPrinter)
{
SvMemoryStream aStream;
pPrinter->Store( aStream );
sal_uInt32 nSize = aStream.TellEnd();
aStream.Seek ( STREAM_SEEK_TO_BEGIN );
Sequence < sal_Int8 > aSequence ( nSize );
aStream.ReadBytes(aSequence.getArray(), nSize);
*pValue <<= aSequence;
}
} break; case HANDLE_SYMBOLS: case HANDLE_USED_SYMBOLS:
{ constbool bUsedSymbolsOnly = (*ppEntries)->mnHandle == HANDLE_USED_SYMBOLS; const std::set< OUString > &rUsedSymbols = pDocSh->GetUsedSymbols();
// this is get const SmSymbolManager& rManager = SmModule::get()->GetSymbolManager();
std::vector < const SmSym * > aVector;
if (0 != nRenderer) throw IllegalArgumentException();
SmDocShell* pDocSh = GetSmDocShell(); if (!pDocSh) throw RuntimeException();
SmPrinterAccess aPrinterAccess( *pDocSh );
Size aPrtPaperSize; if (Printer *pPrinter = aPrinterAccess.GetPrinter())
{ // tdf#157965: UNO methods are expected to return sizes in mm/100
pPrinter->SetMapMode(MapMode(MapUnit::Map100thMM)); // reset in SmPrinterAccess dtor
aPrtPaperSize = pPrinter->GetPaperSize();
}
// if paper size is 0 (usually if no 'real' printer is found), // guess the paper size if (aPrtPaperSize.IsEmpty())
aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MapUnit::Map100thMM);
awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() );
// release SmPrintUIOptions when everything is done. // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor. if (m_pPrintUIOptions->getBoolValue( "IsLastPage" ))
{
m_pPrintUIOptions.reset();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.