37#include <com/sun/star/view/XViewSettingsSupplier.hpp>
38#include <com/sun/star/view/DocumentZoomType.hpp>
51#include <osl/file.hxx>
53#include <unoprnms.hxx>
73 :
vcl::OWizardPage(pPage, pWizard,
"modules/swriter/ui/mmlayoutpage.ui",
"MMLayoutPage")
74 , m_pExampleWrtShell(nullptr)
75 , m_pAddressBlockFormat(nullptr)
76 , m_bIsGreetingInserted(false)
78 , m_xPosition(m_xBuilder->weld_container(
"addresspos"))
79 , m_xAlignToBodyCB(m_xBuilder->weld_check_button(
"align"))
80 , m_xLeftFT(m_xBuilder->weld_label(
"leftft"))
81 , m_xLeftMF(m_xBuilder->weld_metric_spin_button(
"left",
FieldUnit::
CM))
82 , m_xTopMF(m_xBuilder->weld_metric_spin_button(
"top",
FieldUnit::
CM))
83 , m_xGreetingLine(m_xBuilder->weld_container(
"greetingspos"))
84 , m_xUpPB(m_xBuilder->weld_button(
"up"))
85 , m_xDownPB(m_xBuilder->weld_button(
"down"))
86 , m_xZoomLB(m_xBuilder->weld_combo_box(
"zoom"))
88 std::shared_ptr<const SfxFilter> pSfxFlt =
89 SwDocShell::Factory().GetFilterContainer()->
90 GetFilter4FilterName(
"writer8", SfxFilterFlags::EXPORT);
104 uno::Sequence< beans::PropertyValue > aValues =
110 uno::Reference< frame::XStorable > xStore( pView->
GetDocShell()->
GetModel(), uno::UNO_QUERY);
134 m_xLeftMF->connect_value_changed(aFrameHdl);
135 m_xTopMF->connect_value_changed(aFrameHdl);
138 ::SetFieldUnit( *
m_xLeftMF, eFieldUnit );
139 ::SetFieldUnit( *
m_xTopMF, eFieldUnit );
142 m_xUpPB->connect_clicked(aUpDownHdl);
210 if (eReason == ::vcl::WizardTypes::eTravelForward || eReason == ::vcl::WizardTypes::eFinish)
225 const Point& rAddressPosition,
234 if(rAddressPosition.
X() > 0 && rAddressPosition.
Y() > 0)
235 aAddressPosition = rAddressPosition;
238 aAddressPosition, bAlignToBody,
false);
248 return pAddressBlockFormat;
254 const Point& rDestination,
277 OSL_ENSURE( pRet,
"Fly not inserted" );
283 rShell.
Insert(aBlocks[0]);
293 const OUString sDatabaseConditionPrefix(sDBName.replace(
DB_DELIM,
'.'));
303 bool bSpecialReplacementForCountry = (!bIncludeCountry || !rExcludeCountry.isEmpty());
306 Sequence< OUString> aAssignment =
308 const OUString* pAssignment = aAssignment.getConstArray();
309 const OUString sCountryColumn(
310 (aAssignment.getLength() > MM_PART_COUNTRY && !aAssignment[MM_PART_COUNTRY].isEmpty())
311 ? aAssignment[MM_PART_COUNTRY]
312 : rHeaders[MM_PART_COUNTRY].first);
314 OUString sHideParagraphsExpression;
321 OUString sConvertedColumn = aItem.
sText;
322 auto nSize =
std::min(
static_cast<sal_uInt32
>(rHeaders.size()),
323 static_cast<sal_uInt32
>(aAssignment.getLength()));
324 for(sal_uInt32 nColumn = 0; nColumn < nSize; ++nColumn)
327 !pAssignment[nColumn].isEmpty())
329 sConvertedColumn = pAssignment[nColumn];
333 const OUString sDB(sDBName + sConvertedColumn);
335 if(!sHideParagraphsExpression.isEmpty())
336 sHideParagraphsExpression +=
" AND ";
337 sHideParagraphsExpression +=
"![" + sDatabaseConditionPrefix + sConvertedColumn +
"]";
339 if( bSpecialReplacementForCountry && sCountryColumn == sConvertedColumn )
342 if( !rExcludeCountry.isEmpty() )
344 const OUString sExpression(
"[" + sDatabaseConditionPrefix + sCountryColumn +
"]");
346 sExpression +
" != \"" + rExcludeCountry +
"\"",
369 if(bHideEmptyParagraphs)
374 sHideParagraphsExpression.clear();
379 if(bHideEmptyParagraphs && !sHideParagraphsExpression.isEmpty())
457 if( nCurrent >= 0 && nCurrent <
aEntries.getLength())
479 const OUString sConditionBase(
"[" + sCommonBase + sGenderColumn +
"]");
480 const OUString sNameColumnBase(
"[" + sCommonBase + sNameColumn +
"]");
489 OSL_ENSURE(!sGenderColumn.isEmpty() && !rFemaleGenderValue.isEmpty(),
490 "gender settings not available - how to form the condition?");
497 if( nCurrent >= 0 && nCurrent <
aEntries.getLength())
499 const OUString sGreeting =
aEntries[nCurrent];
501 OUString sHideParagraphsExpression;
505 sCondition = sConditionBase +
" != \"" + rFemaleGenderValue
506 +
"\" OR NOT " + sNameColumnBase;
507 sHideParagraphsExpression =
"!" + sNameColumnBase;
510 sCondition = sConditionBase +
" == \"" + rFemaleGenderValue
511 +
"\" OR NOT " + sNameColumnBase;
514 sCondition = sNameColumnBase;
518 if(bHideEmptyParagraphs && !sHideParagraphsExpression.isEmpty())
520 OUString sComplete =
"(" + sCondition +
") OR (" + sHideParagraphsExpression +
")";
531 Sequence< OUString> aAssignment =
533 const OUString* pAssignment = aAssignment.getConstArray();
540 OUString sConvertedColumn = aItem.
sText;
541 auto nSize =
std::min(
static_cast<sal_uInt32
>(rHeaders.size()),
542 static_cast<sal_uInt32
>(aAssignment.getLength()));
543 for(sal_uInt32 nColumn = 0; nColumn < nSize; ++nColumn)
546 !pAssignment[nColumn].isEmpty())
548 sConvertedColumn = pAssignment[nColumn];
553 sDBName + sConvertedColumn,
554 OUString(), 0, &rShell);
575 rShell.
Insert(( nCurrent >= 0 && nCurrent <
aEntries.getLength() )
588 OSL_ENSURE(
nullptr == rShell.
GetTableFormat(),
"What to do with a table here?");
593 m_xExampleContainerWIN->show();
595 Reference< XModel > &
xModel = m_xExampleFrame->GetModel();
597 Reference< XViewSettingsSupplier > xSettings(
xModel->getCurrentController(), UNO_QUERY);
598 m_xViewProperties = xSettings->getViewSettings();
599 auto pXDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(
xModel);
602 OSL_ENSURE(m_pExampleWrtShell,
"No SwWrtShell found!");
603 if(!m_pExampleWrtShell)
609 m_pAddressBlockFormat = InsertAddressFrame(
610 *m_pExampleWrtShell, rConfigItem,
612 m_xAlignToBodyCB->get_active(),
true);
616 InsertGreeting(*m_pExampleWrtShell, rConfigItem,
true);
617 m_bIsGreetingInserted =
true;
620 ZoomHdl_Impl(*m_xZoomLB);
623 m_pExampleWrtShell->GetCurPageDesc()).GetMaster().GetFrameSize();
630 if (!m_pExampleWrtShell)
633 sal_Int16
eType = DocumentZoomType::BY_VALUE;
635 switch (rBox.get_active())
637 case 0 :
eType = DocumentZoomType::ENTIRE_PAGE;
break;
638 case 1 : nZoom = 50;
break;
639 case 2 : nZoom = 75;
break;
640 case 3 : nZoom = 100;
break;
648 m_xExampleFrame->Invalidate();
653 if(!(m_pExampleWrtShell && m_pAddressBlockFormat))
656 tools::Long nLeft =
static_cast< tools::Long >(m_xLeftMF->denormalize(m_xLeftMF->get_value(FieldUnit::TWIP)));
657 tools::Long nTop =
static_cast< tools::Long >(m_xTopMF->denormalize(m_xTopMF->get_value(FieldUnit::TWIP)));
660 m_pExampleWrtShell->GetAttrPool());
661 if (m_xAlignToBodyCB->get_active())
666 m_pExampleWrtShell->GetDoc()->SetFlyFrameAttr( *m_pAddressBlockFormat, aSet );
667 m_xExampleFrame->Invalidate();
672 bool bDown = &rButton == m_xDownPB.get();
673 bool bMoved = m_pExampleWrtShell->MoveParagraph(
SwNodeOffset(bDown ? 1 : -1) );
675 m_pWizard->GetConfigItem().MoveGreeting(bDown ? 1 : -1 );
679 m_pExampleWrtShell->SplitNode();
681 m_xExampleFrame->Invalidate();
686 bool bCheck = rBox.get_active() && rBox.get_sensitive();
687 m_xLeftFT->set_sensitive(!bCheck);
688 m_xLeftMF->set_sensitive(!bCheck);
689 ChangeAddressHdl_Impl( *m_xLeftMF );
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
std::unique_ptr< weld::Builder > m_xBuilder
constexpr tools::Long Y() const
constexpr tools::Long X() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
css::uno::Reference< css::frame::XModel3 > GetModel() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
tools::Long GetHeight() const
tools::Long GetWidth() const
SwMergeAddressItem Next()
void Push()
store a copy of the current cursor on the cursor stack
const SwRect & GetCharRect() const
bool SttEndDoc(bool bStt)
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
bool SetShadowCursorPos(const Point &rPt, SwFillMode eFillMode)
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
SwFrameFormat * GetTableFormat()
bool MoveParagraph(SwNodeOffset nOffset=SwNodeOffset(1))
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
bool DelFullPara()
Remove a complete paragraph.
const SwFrameFormat * NewFlyFrame(const SfxItemSet &rSet, bool bAnchValid=false, SwFrameFormat *pParent=nullptr)
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
const SwFrameFormat * GetFlyFrameFormat() const
Get FlyFrameFormat; for UI macro linkage at Flys.
bool InsertField(SwInsertField_Data &rData)
const SwDBData & GetCurrentDBData() const
css::uno::Sequence< OUString > GetAddressBlocks() const
css::uno::Sequence< OUString > GetGreetings(Gender eType) const
bool IsHideEmptyParagraphs() const
bool IsIncludeCountry() const
bool IsAddressInserted() const
bool IsGreetingInserted() const
OUString & GetExcludeCountry() const
bool IsAddressBlock() const
const std::vector< std::pair< OUString, int > > & GetDefaultAddressHeaders() const
bool IsGreetingLine(bool bInEMail) const
void SetGreetingInserted()
sal_Int32 GetGreetingMoves() const
bool IsIndividualGreeting(bool bInEMail) const
css::uno::Sequence< OUString > GetColumnAssignment(const SwDBData &rDBData) const
sal_Int32 GetCurrentGreeting(Gender eType) const
const OUString & GetFemaleGenderValue() const
void SetAddressInserted()
OUString GetAssignedColumn(sal_uInt32 nColumn) const
std::unique_ptr< weld::Button > m_xUpPB
static void InsertGreeting(SwWrtShell &rShell, SwMailMergeConfigItem const &rConfigItem, bool bExample)
std::unique_ptr< weld::Container > m_xGreetingLine
std::unique_ptr< weld::CustomWeld > m_xExampleContainerWIN
std::unique_ptr< weld::MetricSpinButton > m_xLeftMF
std::unique_ptr< weld::MetricSpinButton > m_xTopMF
std::unique_ptr< SwOneExampleFrame > m_xExampleFrame
static SwFrameFormat * InsertAddressFrame(SwWrtShell &rShell, SwMailMergeConfigItem const &rConfigItem, const Point &rDestination, bool bAlignToBody, bool bExample)
std::unique_ptr< weld::Container > m_xPosition
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
bool m_bIsGreetingInserted
SwWrtShell * m_pExampleWrtShell
static SwFrameFormat * InsertAddressAndGreeting(SwView const *pView, SwMailMergeConfigItem &rConfigItem, const Point &rAddressPos, bool bAlignToBody)
virtual ~SwMailMergeLayoutPage() override
SwMailMergeLayoutPage(weld::Container *pPage, SwMailMergeWizard *pWizard)
std::unique_ptr< weld::CheckButton > m_xAlignToBodyCB
std::unique_ptr< weld::Button > m_xDownPB
SwMailMergeWizard * m_pWizard
std::unique_ptr< weld::ComboBox > m_xZoomLB
virtual void Activate() override
SwFrameFormat * m_pAddressBlockFormat
SwMailMergeConfigItem & GetConfigItem()
Of course Writer needs its own rectangles.
void Top(const tools::Long nTop)
void Left(const tools::Long nLeft)
const SfxItemPool & GetAttrPool() const
SwWrtShell & GetWrtShell() const
SwDocShell * GetDocShell()
Used by the UI to modify the document model.
bool SttPara(bool bSelect=false)
bool GotoFly(const OUString &rName, FlyCntType eType=FLYCNTTYPE_ALL, bool bSelFrame=true)
void Insert(const OUString &)
void SplitNode(bool bAutoFormat=false)
bool DelRight(bool isReplaceHeuristic=false)
bool Pop(SwCursorShell::PopMode, ::std::optional< SwCallLink > &roLink)
static OUString formatPercent(double dNumber, const LanguageTag &rLangTag)
void EnableKillingFile(bool bEnable=true)
OUString const & GetURL() const
@ TabSpace
fill with spaces and tabs
ScXMLEditAttributeMap::Entry const aEntries[]
@ Page
Rect of current page.
@ Minimum
Value in Var-direction gives minimum (can be exceeded but not be less).
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(110)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(107)
#define LINK(Instance, Class, Member)
constexpr tools::Long DEFAULT_ADDRESS_WIDTH
constexpr tools::Long DEFAULT_TOP_DISTANCE
IMPL_LINK(SwMailMergeLayoutPage, ZoomHdl_Impl, weld::ComboBox &, rBox, void)
constexpr tools::Long DEFAULT_ADDRESS_HEIGHT
constexpr tools::Long GREETING_TOP_DISTANCE
IMPL_LINK_NOARG(SwMailMergeLayoutPage, PreviewLoadedHdl_Impl, SwOneExampleFrame &, void)
constexpr tools::Long DEFAULT_LEFT_DISTANCE
constexpr OUStringLiteral aData
OString stripStart(const OString &rIn, char c)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr OUStringLiteral first
constexpr auto toTwips(N number, Length from)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
SwMoveFnCollection const & fnParaStart
Reference< XModel > xModel
constexpr OUStringLiteral UNO_NAME_ZOOM_TYPE
constexpr OUStringLiteral UNO_NAME_ZOOM_VALUE