1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_MMCONFIGITEM_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_MMCONFIGITEM_HXX
21 
22 #include <com/sun/star/uno/Sequence.hxx>
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/view/XSelectionChangeListener.hpp>
25 #include <memory>
26 #include <set>
27 #include <vector>
28 #include <swdbdata.hxx>
29 #include <swdllapi.h>
30 #include "sharedconnection.hxx"
31 
32 namespace com{namespace sun{namespace star{
33     namespace sdbc{
34         class XDataSource;
35         class XResultSet;
36     }
37     namespace sdbcx{
38         class XColumnsSupplier;
39     }
40 }}}
41 
42 class SwMailMergeConfigItem_Impl;
43 class SwView;
44 namespace sw { namespace mark { class IMark; }}
45 
46 struct SwDocMergeInfo
47 {
48     sw::mark::IMark* startPageInTarget;
49     long    nDBRow;
50 };
51 
52 class SW_DLLPUBLIC SwMailMergeConfigItem
53 {
54     std::unique_ptr<SwMailMergeConfigItem_Impl> m_pImpl;
55     //session information - not stored in configuration
56     bool m_bAddressInserted;
57     bool m_bGreetingInserted;
58     sal_Int32 m_nGreetingMoves;
59     std::set<sal_Int32> m_aExcludedRecords;
60     css::uno::Reference<css::view::XSelectionChangeListener> m_xDBChangedListener;
61 
62     OUString m_sSelectedPrinter;
63 
64     SwView* m_pSourceView;
65     SwView* m_pTargetView;
66 public:
67     SwMailMergeConfigItem();
68     ~SwMailMergeConfigItem();
69 
70     enum Gender
71     {
72         FEMALE,
73         MALE,
74         NEUTRAL
75     };
76 
77     void Commit();
78 
79     const std::vector<std::pair<OUString, int>>& GetDefaultAddressHeaders() const;
80 
81     void SetCurrentConnection(
82         css::uno::Reference< css::sdbc::XDataSource> const & xSource,
83         const SharedConnection& rConnection,
84         css::uno::Reference< css::sdbcx::XColumnsSupplier> const & xColumnsSupplier,
85         const SwDBData& rDBData);
86 
87     css::uno::Reference< css::sdbc::XDataSource> const & GetSource() const;
88 
89     SharedConnection const & GetConnection() const;
90 
91     css::uno::Reference< css::sdbcx::XColumnsSupplier> const & GetColumnsSupplier();
92 
93     css::uno::Reference< css::sdbc::XResultSet> const & GetResultSet() const;
94 
95     void DisposeResultSet();
96 
97     OUString& GetFilter() const;
98     void SetFilter(OUString const &);
99 
100     void SetCurrentDBData( const SwDBData& rDBData);
101     const SwDBData& GetCurrentDBData() const;
102 
103     // move absolute, nTarget == -1 -> goto last record
104     sal_Int32 MoveResultSet(sal_Int32 nTarget);
105     sal_Int32 GetResultSetPosition()const;
106     bool IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast);
107 
108     bool IsRecordExcluded(sal_Int32 nRecord) const;
109     void ExcludeRecord(sal_Int32 nRecord, bool bExclude);
110     css::uno::Sequence< css::uno::Any> GetSelection() const;
111 
112     const css::uno::Sequence<OUString>& GetSavedDocuments() const;
113 
114     bool IsOutputToLetter()const;
115     void SetOutputToLetter(bool bSet);
116 
117     bool IsAddressBlock()const;
118     void SetAddressBlock(bool bSet);
119 
120     bool IsHideEmptyParagraphs() const;
121     void SetHideEmptyParagraphs(bool bSet);
122 
123     css::uno::Sequence<OUString> GetAddressBlocks() const;
124     void SetAddressBlocks(const css::uno::Sequence< OUString>& rBlocks);
125 
126     void SetCurrentAddressBlockIndex( sal_Int32 nSet );
127     sal_Int32 GetCurrentAddressBlockIndex() const;
128 
129     bool IsIncludeCountry() const;
130     OUString& GetExcludeCountry() const;
131     void SetCountrySettings(bool bSet, const OUString& sCountry);
132 
133     bool IsIndividualGreeting(bool bInEMail) const;
134     void SetIndividualGreeting(bool bSet, bool bInEMail);
135 
136     bool IsGreetingLine(bool bInEMail) const;
137     void SetGreetingLine(bool bSet, bool bInEMail);
138 
139     css::uno::Sequence<OUString> GetGreetings(Gender eType) const;
140     void SetGreetings(Gender eType, const css::uno::Sequence< OUString>& rBlocks);
141 
142     sal_Int32 GetCurrentGreeting(Gender eType) const;
143     void SetCurrentGreeting(Gender eType, sal_Int32 nIndex);
144 
145     //the content of the gender column that marks it as female
146     const OUString& GetFemaleGenderValue() const;
147     void SetFemaleGenderValue(const OUString& rValue);
148 
149     //returns the assignment in the order of the default headers (GetDefaultAddressHeaders())
150     css::uno::Sequence<OUString> GetColumnAssignment( const SwDBData& rDBData ) const;
151     void SetColumnAssignment(
152         const SwDBData& rDBData,
153         const css::uno::Sequence< OUString>& );
154 
155     bool IsAddressFieldsAssigned() const;
156     bool IsGreetingFieldsAssigned() const;
157 
158     //e-Mail settings:
159     OUString const & GetMailDisplayName() const;
160     void SetMailDisplayName(const OUString& rName);
161 
162     OUString const & GetMailAddress() const;
163     void SetMailAddress(const OUString& rAddress);
164 
165     bool IsMailReplyTo() const;
166     void SetMailReplyTo(bool bSet);
167 
168     OUString const & GetMailReplyTo() const;
169     void SetMailReplyTo(const OUString& rReplyTo);
170 
171     OUString const & GetMailServer() const;
172     void SetMailServer(const OUString& rAddress);
173 
174     sal_Int16 GetMailPort() const;
175     void SetMailPort(sal_Int16 nSet);
176 
177     bool IsSecureConnection() const;
178     void SetSecureConnection(bool bSet);
179 
180     bool IsAuthentication() const;
181     void SetAuthentication(bool bSet);
182 
183     OUString const & GetMailUserName() const;
184     void SetMailUserName(const OUString& rName);
185 
186     OUString const & GetMailPassword() const;
187     void SetMailPassword(const OUString& rPassword);
188 
189     bool IsSMTPAfterPOP() const;
190     void SetSMTPAfterPOP(bool bSet);
191 
192     OUString const & GetInServerName() const;
193     void SetInServerName(const OUString& rServer);
194 
195     sal_Int16 GetInServerPort() const;
196     void SetInServerPort(sal_Int16 nSet);
197 
198     bool IsInServerPOP() const;
199     void SetInServerPOP(bool bSet);
200 
201     OUString const & GetInServerUserName() const;
202     void SetInServerUserName(const OUString& rName);
203 
204     OUString const & GetInServerPassword() const;
205     void SetInServerPassword(const OUString& rPassword);
206 
207     //session information
IsAddressInserted() const208     bool IsAddressInserted() const { return m_bAddressInserted; }
SetAddressInserted()209     void SetAddressInserted()
210     {
211         m_bAddressInserted = true;
212     }
213 
IsGreetingInserted() const214     bool IsGreetingInserted() const
215         { return m_bGreetingInserted; }
SetGreetingInserted()216     void SetGreetingInserted()
217         { m_bGreetingInserted = true; }
218 
219     // counts the moves in the layout page
MoveGreeting(sal_Int32 nMove)220     void MoveGreeting( sal_Int32 nMove) { m_nGreetingMoves += nMove;}
GetGreetingMoves() const221     sal_Int32 GetGreetingMoves() const { return m_nGreetingMoves;}
222 
223     // new source document - reset some flags
224     void DocumentReloaded();
225 
226     bool IsMailAvailable() const;
227 
228     // notify a completed merge, provide the appropriate e-Mail address if available
229     void AddMergedDocument(SwDocMergeInfo const & rInfo);
230     //returns the page and database cursor information of each merged document
231     SwDocMergeInfo& GetDocumentMergeInfo(sal_uInt32 nDocument);
232     sal_uInt32 GetMergedDocumentCount();
233 
GetSelectedPrinter() const234     const OUString&  GetSelectedPrinter() const
235         { return m_sSelectedPrinter; }
SetSelectedPrinter(const OUString & rSet)236     void SetSelectedPrinter(const OUString& rSet)
237         { m_sSelectedPrinter = rSet; }
238 
239     SwView* GetTargetView();
240     void SetTargetView(SwView* pView);
241 
242     SwView* GetSourceView();
243     void SetSourceView(SwView* pView);
244 
245     //helper methods
246     OUString GetAssignedColumn(sal_uInt32 nColumn) const;
247     void stopDBChangeListening();
248     void updateCurrentDBDataFromDocument();
249 };
250 
251 #endif
252 
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
254