36#include <compiler.hxx>
58 VclMessageType::Warning, VclButtonsType::Ok,
99 , bDlgLostFocus(false)
103 , m_xLbPrintArea(m_xBuilder->weld_combo_box(
"lbprintarea"))
104 , m_xEdPrintArea(new
formula::RefEdit(m_xBuilder->weld_entry(
"edprintarea")))
105 , m_xRbPrintArea(new
formula::RefButton(m_xBuilder->weld_button(
"rbprintarea")))
106 , m_xLbRepeatRow(m_xBuilder->weld_combo_box(
"lbrepeatrow"))
107 , m_xEdRepeatRow(new
formula::RefEdit(m_xBuilder->weld_entry(
"edrepeatrow")))
108 , m_xRbRepeatRow(new
formula::RefButton(m_xBuilder->weld_button(
"rbrepeatrow")))
109 , m_xLbRepeatCol(m_xBuilder->weld_combo_box(
"lbrepeatcol"))
110 , m_xEdRepeatCol(new
formula::RefEdit(m_xBuilder->weld_entry(
"edrepeatcol")))
111 , m_xRbRepeatCol(new
formula::RefButton(m_xBuilder->weld_button(
"rbrepeatcol")))
112 , m_xBtnOk(m_xBuilder->weld_button(
"ok"))
113 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
114 , m_xPrintFrame(m_xBuilder->weld_frame(
"printframe"))
115 , m_xRowFrame(m_xBuilder->weld_frame(
"rowframe"))
116 , m_xColFrame(m_xBuilder->weld_frame(
"colframe"))
117 , m_xPrintFrameFT(m_xPrintFrame->weld_label_widget())
118 , m_xRowFrameFT(m_xRowFrame->weld_label_widget())
119 , m_xColFrameFT(m_xColFrame->weld_label_widget())
133 assert(pScDocSh &&
"Current DocumentShell not found :-(");
155 DoClose( ScPrintAreasDlgWrapper::GetChildWindowId() );
183 aVal = aVal.replaceAt( aSel.
Min(), aSel.
Len(),
aStr );
205 sal_Int32 nLen = aVal.getLength();
264 for (sal_uInt16
i=0;
i<nRangeCount;
i++)
269 if ( !aStrRange.isEmpty() )
270 aStrRange += OUStringChar(sep);
299 OUString aRangeStr = pEd->
GetText();
322 bool bPrintAreaOk =
true;
323 if ( !aStrPrintArea.isEmpty() )
332 for ( sal_Int32 nIdx = 0; nIdx >= 0; )
334 const OUString aOne = aStrPrintArea.getToken(0, sep, nIdx);
336 if ((nResult & nValidRange) != nValidRange)
339 if ((nAddrResult & nValidAddr) != nValidAddr)
341 bPrintAreaOk =
false;
348 bool bRepeatRowOk = aStrRepeatRow.isEmpty();
352 bool bRepeatColOk = aStrRepeatCol.isEmpty();
358 bOk = (bPrintAreaOk && bRepeatRowOk && bRepeatColOk);
408 if (!pRangeNames || pRangeNames->
empty())
412 for (
const auto& rEntry : *pRangeNames)
419 OUString
aName = rEntry.second->GetName();
420 OUString aSymbol = rEntry.second->GetSymbol();
448 if (m_xBtnOk.get() == &rBtn)
450 if ( Impl_CheckRefStrings() )
460 SfxBoolItem aEntireSheet( FN_PARAM_4, bEntireSheet );
462 bool bDataChanged = bEntireSheet != pDoc->IsPrintEntireSheet( nCurTab );
466 bDataChanged |= Impl_GetItem( m_xEdPrintArea.get(), aPrintArea );
471 bDataChanged |= Impl_GetItem( m_xEdRepeatRow.get(), aRepeatRow );
475 bDataChanged |= Impl_GetItem( m_xEdRepeatCol.get(), aRepeatCol );
479 SetDispatcherLock(
false );
482 SfxCallMode::SLOT | SfxCallMode::RECORD,
483 { &aPrintArea, &aRepeatRow, &aRepeatCol, &aEntireSheet });
489 else if (m_xBtnCancel.get() == &rBtn)
495 m_pRefInputEdit = &rCtrl;
500 if (&rCtrl == m_xLbPrintArea.get())
501 m_pRefInputEdit = m_xEdPrintArea.get();
502 else if (&rCtrl == m_xLbRepeatRow.get())
503 m_pRefInputEdit = m_xEdRepeatRow.get();
504 else if (&rCtrl == m_xLbRepeatCol.get())
505 m_pRefInputEdit = m_xEdRepeatCol.get();
510 const sal_Int32 nSelPos = rLb.get_active();
518 if (&rLb == m_xLbPrintArea.get())
520 pEd = m_xEdPrintArea.get();
524 else if (&rLb == m_xLbRepeatCol.get())
525 pEd = m_xEdRepeatCol.get();
526 else if (&rLb == m_xLbRepeatRow.get())
527 pEd = m_xEdRepeatRow.get();
532 if( (nSelPos == 0) || (nSelPos == nAllSheetPos) )
534 else if( nSelPos >= nFirstCustomPos )
535 pEd->
SetText(rLb.get_id(nSelPos));
546 if( &rEd == m_xEdPrintArea.get() )
548 pLb = m_xLbPrintArea.get();
552 else if( &rEd == m_xEdRepeatCol.get() )
553 pLb = m_xLbRepeatCol.get();
554 else if( &rEd == m_xEdRepeatRow.get() )
555 pLb = m_xLbRepeatRow.get();
560 const sal_Int32 nEntryCount = pLb->
get_count();
561 OUString aStrEd( rEd.GetText() );
562 OUString aEdUpper = aStrEd.toAsciiUpperCase();
564 if ( (nEntryCount > nFirstCustomPos) && !aStrEd.isEmpty() )
569 for (
i=nFirstCustomPos;
i<nEntryCount && !bFound;
i++ )
571 const OUString& rSymbol = pLb->
get_id(
i);
572 bFound = (rSymbol == aStrEd || rSymbol == aEdUpper);
578 pLb->
set_active( !aStrEd.isEmpty() ? nUserDefPos : 0 );
591 OUString
aStr = rStr;
592 sal_Int32 nLen =
aStr.getLength();
594 bool bStrOk = ( nLen > 0 ) && ( bIsRow ? ( nLen < 6 ) : ( nLen < 4 ) );
598 if (
'$' ==
aStr[0] )
607 sal_Int32
n =
aStr.toInt32();
636 sal_Int32 nLen =
aStr.size();
643 if (
aStr[0] != preUpper &&
aStr[0] != preLower)
646 std::u16string_view aNumStr =
aStr.substr(1);
659 rVal =
static_cast<SCCOLROW>(nNum-1);
700 sal_Int32 nLen =
aStr.size();
701 bool bEndPos =
false;
702 for( sal_Int32
i = 0;
i < nLen; ++
i )
737 aBuf += OUStringChar(c);
773 const ScAddress& rStart = oRange->aStart;
779 rStr += rStart.
Format(nFmt, &rDoc, eConv);
780 if ((bIsRow && rStart.
Row() != rEnd.
Row()) || (!bIsRow && rStart.
Col() != rEnd.
Col()))
783 rStr += rEnd.
Format(nFmt, &rDoc, eConv);
bool AlphaToCol(const ScDocument &rDoc, SCCOL &rCol, std::u16string_view rStr)
get column number of A..IV... string
static void lcl_GetRepeatRangeString(std::optional< ScRange > oRange, const ScDocument &rDoc, bool bIsRow, OUString &rStr)
static bool lcl_CheckOne_XL_R1C1(const ScDocument &rDoc, std::u16string_view aStr, bool bIsRow, SCCOLROW &rVal)
static bool lcl_CheckRepeatString(std::u16string_view aStr, const ScDocument &rDoc, bool bIsRow, ScRange *pRange)
static bool lcl_CheckOne_XL_A1(const ScDocument &rDoc, const OUString &rStr, bool bIsRow, SCCOLROW &rVal)
static bool lcl_CheckOne_OOO(const ScDocument &rDoc, const OUString &rStr, bool bIsRow, SCCOLROW &rVal)
static bool lcl_CheckRepeatOne(const ScDocument &rDoc, const OUString &rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW &rVal)
IMPL_LINK(ScPrintAreasDlg, Impl_BtnHdl, weld::Button &, rBtn, void)
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static bool isAsciiNumeric(std::u16string_view rStr)
void SetValue(const OUString &rTheValue)
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
const ScDocument & GetDocument() const
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC const ScRange * GetPrintRange(SCTAB nTab, sal_uInt16 nPos)
SC_DLLPUBLIC std::optional< ScRange > GetRepeatColRange(SCTAB nTab)
SC_DLLPUBLIC std::optional< ScRange > GetRepeatRowRange(SCTAB nTab)
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount(SCTAB nTab)
bool IsPrintEntireSheet(SCTAB nTab) const
Returns true, if the specified sheet is always printed.
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
std::unique_ptr< formula::RefButton > m_xRbPrintArea
std::unique_ptr< weld::Button > m_xBtnOk
bool Impl_CheckRefStrings()
virtual void AddRefEntry() override
std::unique_ptr< weld::ComboBox > m_xLbRepeatRow
virtual ~ScPrintAreasDlg() override
virtual void Deactivate() override
std::unique_ptr< weld::ComboBox > m_xLbPrintArea
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
std::unique_ptr< formula::RefEdit > m_xEdRepeatRow
std::unique_ptr< weld::Label > m_xPrintFrameFT
ScPrintAreasDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent)
std::unique_ptr< formula::RefEdit > m_xEdPrintArea
formula::RefEdit * m_pRefInputEdit
std::unique_ptr< weld::Button > m_xBtnCancel
std::unique_ptr< weld::Label > m_xRowFrameFT
virtual bool IsTableLocked() const override
virtual void SetActive() override
std::unique_ptr< formula::RefEdit > m_xEdRepeatCol
std::unique_ptr< formula::RefButton > m_xRbRepeatCol
std::unique_ptr< formula::RefButton > m_xRbRepeatRow
std::unique_ptr< weld::ComboBox > m_xLbRepeatCol
std::unique_ptr< weld::Label > m_xColFrameFT
virtual void Close() override
bool Impl_GetItem(const formula::RefEdit *pEd, SfxStringItem &rItem)
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
ScRefFlags Parse(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, ScAddress::ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
virtual void RefInputDone(bool bForced=false) override
bool DoClose(sal_uInt16 nId)
ScViewData & GetViewData()
ScMarkData & GetMarkData()
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
SfxDispatcher * GetDispatcher() const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual OUString get_id(int pos) const=0
virtual void set_active(int pos)=0
virtual int get_count() const=0
virtual SfxBindings & GetBindings() override
#define LINK(Instance, Class, Member)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
OUString ScResId(TranslateId aId)
SCROW GetMaxRowCount() const
SCCOL GetMaxColCount() const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW